package com.hibase.core.excel.vo.bizdata.detail;

import com.hibase.core.excel.enums.FieldTypeEnum;
import com.hibase.core.excel.vo.BaseViewExcelVO;
import com.hibase.core.web.annotation.HibaseValid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * Excel 业务数据明细表
 *
 * @author <a href="mailto:xiongliyi@hichain.com">Ian Xiong</a>
 * @since 1.4.35-V2
 */
@Data
@HibaseValid
@ApiModel(value = "MdsExcelBizDataDetailInsertVO", description = "Excel 业务数据明细新增模型")
public class MdsExcelBizDataDetailInsertVO extends BaseViewExcelVO {
    @ApiModelProperty(value = "业务数据集ID", required = true)
    @NotEmpty(message = "业务数据集ID不能为空")
    private String bizDataId;

    @ApiModelProperty(value = "字段键", required = true, example = "mds_user$mobile", notes = "与数据库名称和字段保持一致")
    @NotEmpty(message = "业务数据集ID不能为空,并且保证唯一")
    private String fieldKey;

    @ApiModelProperty(value = "字段名称", required = true, example = "手机号", notes = "前端展示名称")
    @NotEmpty(message = "字段名称不能为空")
    private String fieldName;

    @ApiModelProperty(value = "字段类型", required = true, example = "java.lang.String", notes = "字段类型")
    @NotNull(message = "字段类型不能为空")
    private FieldTypeEnum fieldType;

    @ApiModelProperty(value = "是否必填", required = true)
    private Boolean notNull;

    @ApiModelProperty(value = "字段排序码")
    private Integer fieldSort;


    public void setFieldType(String key) {
        this.fieldType = FieldTypeEnum.keyOf(key);
    }

    public void setParentId(String parentId) {
        this.bizDataId = parentId;
    }
}
